const mongoose = require("./db");
const { getId } = require("../utils/getMethods");

const activityRuleSchema = new mongoose.Schema({
  id: {
    type: Number,
    default: () => getId,
  },
  ruleDesc: {
    type: String,
    required: true,
  },
});
const categoryListSchema = new mongoose.Schema({
  id: {
    type: Number,
    unique: true,
    required: true,
    default: () => getId,
  },
  name: {
    type: String,
    required: true,
  },
  imgUrl: {
    type: String,
    required: true,
  },
  parentId: {
    type: Number,
    required: true,
  },
  status: {
    type: Number,
    required: true,
  },
});
const imagesListSchema = new mongoose.Schema({
  id: {
    type: Number,
    default: () => getId,
  },
  skuId: {
    type: Number,
  },
  imgName: {
    type: String,
  },
  imgUrl: {
    type: String,
  },
});
const skuAttrValueListSchema = new mongoose.Schema({
  id: {
    type: Number,
    default: () => getId,
  },
  skuId: {
    type: Number,
  },
  attrId: {
    type: Number,
  },
  attrName: {
    type: String,
  },
  attrValue: {
    type: String,
  },
});
const skuProductListSchema = new mongoose.Schema({
  id: {
    type: String,
    // unique: true,
    required: true,
  },
  keyword: {
    type: String,
    required: true,
  },
  skuType: {
    type: Number,
    required: true,
    default: 1,
  },
  isNewPerson: {
    type: Number,
    default: 0,
  },
  categoryId: {
    type: Number,
    required: true,
    // unique: true,
    default: () => getId,
  },
  categoryName: {
    type: String,
  },
  imgUrl: {
    type: String,
    required: true,
  },
  title: {
    type: String,
    required: true,
  },
  price: {
    type: Number,
    required: true,
  },
  perLimit: {
    type: Number,
    required: true,
  },
  sale: {
    type: Number,
    required: true,
  },
  stock:{
    type:Number,
    required:true,
  },
  skuPosterList:{
    type:Array
  },
  skuImagesList:{
    type:Array
  },
  ruleList: Array,
  marketPrice: Number,
  skuName: String,
});

const activityRuleListModel = mongoose.model(
  "activityRuleList",
  activityRuleSchema,
  "activityRuleList"
);
const skuProductListModel = mongoose.model(
  "skuProductList",
  skuProductListSchema,
  "skuProductList"
);
const categoryListModel = mongoose.model(
  "categoryList",
  categoryListSchema,
  "categoryList"
);
const imagesListModel = mongoose.model(
  "imagesList",
  imagesListSchema,
  "imagesList"
);
const skuAttrValueListModel = mongoose.model(
  "skuAttrValueList",
  skuAttrValueListSchema,
  "skuAttrValueList"
);
// skuProductListModel.create({
//   categoryId: 6,
//   categoryName: "categor1",
//   id: 2289324483756460,
//   imgUrl:
//     "https://img.zcool.cn/community/0120785dd216a7a8012053c0271793.jpg@1280w_1l_2o_100sh.jpg",
//   isNewPerson: 0,
//   keyword: "1213456465",
//   marketPrice: 23,
//   perLimit: 1,
//   price: 23,
//   ruleList: ["全场2块", "买5减4"],
//   sale: 1,
//   skuName: "厨具1",
//   skuType: 1,
//   stock: 69,
//   title: "厨具",
//   skuPosterList:[],
//   skuImagesList:[]
// });
module.exports = {
  activityRuleListModel,
  categoryListModel,
  skuProductListModel,
  imagesListModel,
  skuAttrValueListModel,
};
